#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//全局变量head头指针，num记录节点数目。
typedef struct node {
    int data;
    struct node* next;
}Node;

Node* head = NULL;
int num=0;
void get(int x) {
    if(x>num) {
        printf("get fail\n");
        return;    
    }
    Node* temp=head;
    int rev;
    while(x) {
        rev=temp->data;
        temp=temp->next;
        x--;
    }
    printf("%d\n",rev);
}

void insert(int x,int a) {
    if(x>num+1) {
        printf("insert fail\n");
        return;    
    }
    Node* insert = (Node*)malloc(sizeof(Node));
    insert->data = a;
    insert->next = NULL;
    if(x==1) {
        insert->next=head;
        head=insert;
        printf("insert OK\n");
        num++;
        return;
    }
    Node* temp=head;    
    while(x-2) {
        temp=temp->next;
        x--;
    }
    insert->next=temp->next;
    temp->next=insert;
    printf("insert OK\n");
    num++;
}

void delete(int x) {
    if(x>num) {
        printf("delete fail\n");
        return;    
    }
    if(x==1) {
        head=head->next;
        printf("delete OK\n");
        num--;
        return;
    }
    Node* temp=head;    
    while(x-2) {
        temp=temp->next;
        x--;
    }
    temp->next=temp->next->next;
    printf("delete OK\n");
    num--;
}

void show() {
    if(num==0) {
        printf("Link list is empty\n");
        return;
    }
    Node* temp = head;
    while (temp != NULL)
    {
        printf("%d ",temp->data);
        temp = temp->next;
    }
    printf("\n");
}

void head_insert(int a)
{
    Node* temp = (Node*)malloc(sizeof(Node));
    temp->data = a;
    temp->next = head;
    head = temp;
    num++;
}

int main() {
    int n,x,m;
    scanf("%d",&n);
    for (int i = 0; i < n; i++) {
        scanf("%d",&x);
        head_insert(x);
    }
    scanf("%d",&m);
    char str[10];
    int index,data;
    for (int i = 0; i < m; i++) {
        scanf("%s",str);
        if(strcmp(str,"show")==0) show();
        else if(strcmp(str,"delete")==0) {
            scanf("%d",&index);
            delete(index);
        }
        else if(strcmp(str,"get")==0) {
            scanf("%d",&index);
            get(index);
        }
        else if(strcmp(str,"insert")==0) {
            scanf("%d %d",&index,&data);
            insert(index,data);
        }
    }
    return 0;
}